
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 22652
 * Date: 2024-05-23
 * Time: 10:24
 */
@WebServlet("/method")
public class MethodServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("有一个Get请求");
        resp.setContentType("text/html;charset=UTF-8");
        resp.getWriter().write("doGet,处理了");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("有一个Post请求");
        resp.setContentType("text/html;charset=UTF-8");
        resp.getWriter().write("doPost,处理了");
    }

    @Override
    protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("有一个Put请求");
        resp.setContentType("text/html;charset=UTF-8");
        resp.getWriter().write("doPut,处理了");
    }

    @Override
    protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("有一个Delete请求");
        resp.setContentType("text/html;charset=UTF-8");
        resp.getWriter().write("doDelete,处理了");
    }
}
